<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      let arr1 = [1, 3, 5, 6, 8];
      let arr2 = [7, 5, 2, 5, 3, 7];
      console.log(...arr1); //展开一个数组
      let arr3 = [...arr1, ...arr2];

      function sum(...numbers) {
        return numbers.reduce((preValue, currentValue) => {
          return preValue + currentValue;
        });
      }

      console.log(sum(1, 6, 2, 6));

      //...运算符不能展开对象
      let person = {
        name: "lucy",
        age: 18,
      };
      //复制对象
      let person2 = { ...person };
      person.name = "fuckoff";
      console.log(person);
      console.log(person2);

      //合并
      let person3 = { ...person, name: "jack", address: "地球" };
      console.log(person3);
    </script>
  </body>
</html>
